package com.lzw.breezeNovel.webApp.mapper.video;

import com.lzw.breezeNovel.model.entity.pojo.video.VideoLike;
import org.apache.ibatis.annotations.*;


/**
 * @author 清风明月
 * @Package com.lzw.breezeNovel.webApp.mapper
 * @date 2025/3/23
 * @description
 */
@Mapper
@SuppressWarnings("all")
public interface VideoLikeMapper {

    /**
     * 判断用户是否点赞过
     * @param shortId
     * @param userId
     * @return
     */
    @Select("SELECT EXISTS(SELECT 1 FROM video_likes WHERE video_id = #{shortId} AND user_id = #{userId})")
    Integer isLike(Long shortId, Long userId);

    /**
     * 取消点赞
     * @param shortId
     * @param userId
     */
    @Delete("delete  from video_likes where video_id = #{shortId} and user_id = #{userId}")
    void unlike(Long shortId, Long userId);

    /**
     * 点赞
     * @param videoLike
     */
    @Insert("insert into video_likes(video_id,user_id) values(#{video.videoId},#{video.userId})")
    void like(@Param("video") VideoLike videoLike);


    /**
     * 批量删除点赞记录
     * @param videoId
     */
    void deleteVideoLikeByVideoId(Long videoId);

}
